package com.ludomancy.breathe;

public class Cat extends RoomObject
{
	private int stillTurns = 0;
	public boolean paralized = false;
	
	public Cat()
	{
		super(Game.game.getValidRandomLocation(Game.game.position));
	}

	public void doTurn()
	{
		if(Game.game.tree.fallen && Game.game.fire.isFiring() && Game.game.isOutOfControl() && !paralized)
		{
			// I will seek refuge there
			Game.game.addResponse("The cat feels you are out of control. Cornered by the fire, runs away. You hear the christmas tree ornaments. It took refuge inside it.");
			// I move into the tree...
			position = Game.game.tree.position;
			// and get paralized there
			paralized = true;
		}
		else
		{
			if(!paralized)
			{
				if(Game.game.position == position)
				{
					if(Game.game.isDesperate())
					{
						Game.game.addResponse("You almost step into the cat, but it is scared of you and alertly avoids your feet.");
					}
					else
					{
						Game.game.addResponse("You step on the cat's tail. It goes away with a noisy complaint.");
					}
					move();
				}
				else
				{
					stillTurns++;
					if(stillTurns == 8)
					{
						stillTurns = 0;
						if(paralized)
						{
							Game.game.addResponse("You hear the cat make desperate noises and christmas ornaments breaking.");
						}
						else
						{
							if(!Game.game.isOutOfControl())
							{
								Game.game.addResponse("You hear the cat jumping around.");
							}
							move();
						}
					}
					
				}
			}
		}
	}
	
	private void move()
	{
		// move somewhere
		position = Game.game.getValidRandomLocation(Game.game.position);		
	}

	public void onBump()
	{
	}

	public void processOption(Option option)
	{
	}

	public boolean isPassable()
	{
		return true;
	}
}